using Headsight.BPMN2WF.BPMN.Model;
using Headsight.BPMN2WF.Testing.TestObjCtors;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Headsight.BPMN2WF.Testing.TestObjCtorsTest
{
    [TestClass]
    public class BPMNProcessCtorTest
    {
        private BPMNProcessCtor _sut;
        private BPMNFlowNode _flowNode1;
        private BPMNFlowNode _flowNode2;
        private BPMNFlowNode _flowNode3;
        private BPMNSequenceFlow _seqFlow1;

        [TestInitialize]
        public void SetUp()
        {
            _flowNode1 = new BPMNFlowNodeCtor().Create();
            _flowNode2 = new BPMNFlowNodeCtor().Create();
            _flowNode3 = new BPMNFlowNodeCtor().Create();

            _seqFlow1 = new BPMNSequenceFlowCtor().WithId("id").Create();

            _sut = new BPMNProcessCtor();
        }

        [TestMethod]
        public void Create()
        {
            var actual = _sut.Create();

            Assert.IsNotNull(actual);
        }

        [TestMethod]
        public void With_BPMNFlowNode_is_chaining()
        {
            Assert.AreSame(_sut, _sut.With(_flowNode1));
        }

        [TestMethod]
        public void With_BPMNFlowNode_Create()
        {
            var actual = _sut.With(_flowNode1).With(_flowNode2, _flowNode3).Create();

            Assert.AreEqual(3, actual.BPMNFlowNodes.Count);
            Assert.AreEqual(true, actual.BPMNFlowNodes.Contains(_flowNode1));
            Assert.AreEqual(true, actual.BPMNFlowNodes.Contains(_flowNode2));
            Assert.AreEqual(true, actual.BPMNFlowNodes.Contains(_flowNode3));

            Assert.AreEqual(_flowNode1, actual.GetBPMNFlowNodeById(_flowNode1.Id));
            Assert.AreEqual(_flowNode2, actual.GetBPMNFlowNodeById(_flowNode2.Id));
            Assert.AreEqual(_flowNode3, actual.GetBPMNFlowNodeById(_flowNode3.Id));
        }

        [TestMethod]
        public void With_BPMNSequenceFlow_is_chaining()
        {
            Assert.AreSame(_sut, _sut.With(_seqFlow1));
        }

        [TestMethod]
        public void With_BPMNSequenceFlow_Create()
        {
            var actual = _sut.With(_seqFlow1).Create();

            Assert.AreEqual(1, actual.BPMNSequenceFlows.Count);
            Assert.AreEqual(true, actual.BPMNSequenceFlows.Contains(_seqFlow1));

            Assert.AreSame(_seqFlow1, actual.GetBPMNSequenceFlowById(_seqFlow1.Id));
        }
    }
}